package com.abel.bigwater.dataserver.model.ewide

import io.netty.buffer.ByteBuf

class KmingRepondShutdown : TermData(KmingDataType.TermShutdownComm, 2) {
    /**
     * 0x00 - 不能结束， 再等待20秒钟
     */
    var sessionReponseType: SessionReponseType? = null

    override fun bufLength() = 2

    override fun parseBuf(buf: ByteBuf): Boolean {
        assert(type == KmingDataType.findByCode(buf.readUnsignedByte()))

        sessionReponseType = SessionReponseType.findByCode(buf.readByte())

        return true
    }

    override fun pack(buf: ByteBuf) {
        buf.apply {
            writeByte(type.code.toInt())

            writeByte(sessionReponseType!!.code.toInt())

            buf.writeBytes(this)
        }
    }
}